package com.yicheng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yicheng.dao.GoodsDao;
import com.yicheng.entity.Goods;
import com.yicheng.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements GoodsService {

    @Autowired
    private GoodsDao goodsDao;

//    @Override
//    public List<Goods> orderByPresent(){
//        LambdaQueryWrapper<Goods> lwq = new LambdaQueryWrapper<>();
//        lwq.orderBy(true, true, Goods::getPresentPrice);
//        return goodsDao.selectList(lwq);
//    }

    @Override
    public IPage<Goods> getPage(int currentPage, int pageSize) {

        LambdaQueryWrapper<Goods> lwq = new LambdaQueryWrapper<>();
        lwq.orderBy(true, true, Goods::getPresentPrice);
//        lwq.orderByAsc(Goods::getPresentPrice);

        IPage<Goods> page = new Page<>(currentPage, pageSize);
        goodsDao.selectPage(page, lwq);
        return page;
    }
}
